import {Directive, Component, HostListener} from 'angular2/src/core/metadata'

@Directive({
    selector: 'button[counting]'
})
class CountClicks {
  numberOfClicks = 0;
  @HostListener('click', ['$event.target'])
  onClick(btn: any) {
    console.log("button", btn, "number of clicks:", this.numberOfClicks++);
  }
}

@Component({
  selector: 'app',
  template: `<button counting>Increment</button>`,
  directives: [CountClicks]
})
class App {}